#!/bin/bash

# Common setup for all installation scripts

function echo_and_log {
    echo $1
    logger -- $1
}

#Define source root directory
# if [ ! -n "$1" ] ;then
    SOURCE_ROOT="/vagrant"
# else
#    SOURCE_ROOT=$1
#fi

HOST_ENV=${HOSTNAME#*.}
PC_ENV=`echo ${HOSTNAME}|awk -F '.' '{print $2}'`

WEB_DIR=/var/lib/foxit_ucx

# Figuring out our download server
DL_SERVER_FILE_NAME=/tmp/download_server.txt
#if [ ! -e $DL_SERVER_FILE_NAME ] || [ `find "$DL_SERVER_FILE_NAME" -mmin +1440` ]; then
    echo "Download server info outdated, fetching..."
    sudo curl -s -o $DL_SERVER_FILE_NAME http://www.sumilux.com/get-download-server.php
#fi
DL_SERVER=`cat $DL_SERVER_FILE_NAME`
# echo Now using download server $DL_SERVER ...

# Setting YUM architecture "i386" or "x86_64" for later repo operations
YUM_BASEARCH=`uname -i`
YUM_ARCH=`uname -m`
YUM_SYS=`cat /etc/redhat-release |awk -F" " '{print$(NF-1)}'`

ID_RSA_PATH=$SOURCE_ROOT/vagrant/svcconfig/id_rsa/id_rsa
sudo chmod 600 ${ID_RSA_PATH}
